# Contributor: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
# Contributor: Galen Abell <galen@galenabell.com>
# Maintainer: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
pkgname=prosody-modules
pkgver=0.11_hg20200329
_commit=fd582067c732
pkgrel=0
pkgdesc="modules for the prosody XMPP server"
url="https://modules.prosody.im/"
arch="noarch"
license="MIT"
# Create one subpackage for every modules considered stable [1]. In addition
# the modules mod-auth-ldap, mod-auth-pam, mod-conversejs mod-mam, and
# mod-smacks are included.
# [1]: https://modules.prosody.im/stage_stable.html
subpackages="
	prosody-mod-auth_ldap
	prosody-mod-auth_pam
	prosody-mod-auth_sql
	prosody-mod-block_registrations
	prosody-mod-bookmarks
	prosody-mod-broadcast
	prosody-mod-c2s_conn_throttle
	prosody-mod-cloud_notify
	prosody-mod-conversejs
	prosody-mod-host_guard
	prosody-mod-http_upload_external
	prosody-mod-ipcheck
	prosody-mod-log_auth
	prosody-mod-log_slow_events
	prosody-mod-mam
	prosody-mod-muc_cloud_notify
	prosody-mod-pastebin
	prosody-mod-register_json
	prosody-mod-register_redirect
	prosody-mod-reload_modules
	prosody-mod-require_otr
	prosody-mod-s2s_idle_timeout
	prosody-mod-saslname
	prosody-mod-server_status
	prosody-mod-smacks
	prosody-mod-stanza_counter
	prosody-mod-support_contact
	prosody-mod-vcard_muc
	prosody-mod-webpresence"
depends="prosody $subpackages"
source="$pkgname-$_commit.tar.gz::https://hg.prosody.im/prosody-modules/archive/$_commit.tar.gz"
options="!check"
builddir="$srcdir/Community-Modules-$_commit"

package() {
	mkdir -p "$pkgdir"
}

_package_mod() {
	mod="mod_${subpkgname#prosody-mod-}"
	cd "$builddir"
	if [ -f "$mod/$mod.lua" ] ; then
		# Module is a single file
		install -Dm644 "$mod/$mod.lua" "$subpkgdir/usr/lib/prosody/modules/$mod.lua"
	else
		# Module is a folder
		mkdir -p "$subpkgdir/usr/lib/prosody/modules"
		cp -R "$mod/$mod" "$subpkgdir/usr/lib/prosody/modules/"
	fi
}

auth_ldap() {
	depends="prosody lua5.2-ldap"
	pkgdesc="prosody module providing client authentication using LDAP"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

auth_pam() {
	depends="prosody"
	pkgdesc="prosody module providing client authentication using PAM"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

auth_sql() {
	depends="prosody"
	pkgdesc="prosody module providing client authentication using SQL db queries"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

block_registrations() {
	depends="prosody"
	pkgdesc="prosody module to allow restricting registration of certain users"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

bookmarks() {
	depends="prosody"
	pkgdesc="prosody module to synchronise bookmarks between Private XML and PEP"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

broadcast() {
	depends="prosody"
	pkgdesc="prosody module similiar to mod_announce, but compatible with shitty clients"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

c2s_conn_throttle() {
	depends="prosody"
	pkgdesc="prosody module limiting the frequency of login attempts"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

cloud_notify() {
	depends="prosody"
	pkgdesc="prosody module for cloud push notifications"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

conversejs() {
	depends="prosody"
	pkgdesc="prosody module to serve an HTML+JavaScript XMPP client via http"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

http_upload_external() {
	depends="prosody"
	pkgdesc="prosody module that delegates http upload handling to another service"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

host_guard() {
	depends="prosody"
	pkgdesc="prosody module configure access for each virtual host XMPP hosts"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

ipcheck() {
	depends="prosody"
	pkgdesc="prosody module implementing XEP-0279: Server IP Check"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

log_auth() {
	depends="prosody"
	pkgdesc="prosody module to log the clients IP address for failed login attempts"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

log_slow_events() {
	depends="prosody"
	pkgdesc="prosody module to log when event handlers (e.g. of modules) perform poorly"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

mam() {
	depends="prosody"
	pkgdesc="prosody module implementing XEP-0313: Message Archive Management"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

muc_cloud_notify() {
	depends="prosody"
	pkgdesc="prosody module cloud push notifications for muc"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

pastebin() {
	depends="prosody"
	pkgdesc="prosody module moving large messages in MUCs to a build-in webserver"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

register_json() {
	depends="prosody"
	pkgdesc="prosody module to handle registrations via HTTP POST requests containg JSON"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	# This module does not follow naming conventions, package it manually :-(
	mod="mod_${subpkgname#prosody-mod-}"
	cd "$builddir"
	mkdir -p "$subpkgdir/usr/lib/prosody/modules"
	cp -R "$mod/${mod#mod_}" "$subpkgdir/usr/lib/prosody/modules/"
}

register_redirect() {
	depends="prosody"
	pkgdesc="prosody module showing instructions on how to register for out-of-band methods"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

reload_modules() {
	depends="prosody"
	pkgdesc="prosody module that reloads modules when the config file changes"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

require_otr() {
	depends="prosody"
	pkgdesc="prosody module that forces clients to use OTR encryption"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

s2s_idle_timeout() {
	depends="prosody"
	pkgdesc="prosody module that closes idle s2s connections after a while"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

saslname() {
	depends="prosody"
	pkgdesc="prosody module that implements XEP-0233 to advertise the Kerberes principal name"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

server_status() {
	depends="prosody prosody-mod-stanza_counter"
	pkgdesc="prosody module that publishes the server status as XML/JSON"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

smacks() {
	depends="prosody"
	pkgdesc="prosody module that implements XEP-0198: Stream Management"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

stanza_counter() {
	depends="prosody"
	pkgdesc="prosody module that counts in- and outgoing stanzas"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

support_contact() {
	depends="prosody"
	pkgdesc="prosody module that adds a default contact to newly registered accounts"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

vcard_muc() {
	depends="prosody"
	pkgdesc="prosody module vcard support for muc"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

webpresence() {
	depends="prosody"
	pkgdesc="prosody module that publishes the online status of jabber uses e.g. in a blog"
	url="https://modules.prosody.im/mod_${subpkgname#prosody-mod-}.html"
	_package_mod
}

sha512sums="453cf9e9f7de30355abad35649232263259723c60941020f677d1994f8e118e70b872e737435a0a706c8e0138e2500d75ec8d0755974dbadcc5f16e4c8079f14  prosody-modules-fd582067c732.tar.gz"
